import { SET_SHORTCUT_KEY } from './mutation-types'
import api from '../../../api/config/shortcutKey'
import * as globalTypes from '../../../mutation-types'

export const setShortcut = async ({commit}, data) => {
  try {
    await api.updateShortcut(data)
    commit(SET_SHORTCUT_KEY, data || {})
  } catch (error) {
    commit(globalTypes.SET_ERROR, 'message.default_tips')
  }
}

export const getShortcut = async ({commit}) => {
  try {
    const res = await api.getShortcut({})
    commit(SET_SHORTCUT_KEY, res.data || {})
  } catch (error) {
    commit(globalTypes.SET_ERROR, 'message.default_tips')
  }
}
